import pymysql

class DB:
    def __init__(self):
        self.conn = pymysql.connect(host="localhost",port=3306,user="root",password="root",db="p9db",charset="utf8",cursorclass=pymysql.cursors.DictCursor)
        self.cursor = self.conn.cursor()
    def find(self,sql):
        self.cursor.execute(sql)
        return self.cursor.fetchone()

    def find_all(self,sql):
        self.cursor.execute(sql)
        return self.cursor.fetchall()

    def update(self,sql):
        self.cursor.execute(sql)
        self.conn.commit()
        
    def close(self,sql):
        self.cursor.close()
        self.conn.close()

db1 = DB()